Processor unit for executing event processes in real time without causing process interference

ABSTRACT

A processor unit executes a failure detection program for a vehicle. The failure detection program includes a first failure detection process of a high priority level, a second failure detection process of a moderate priority level and a memory manipulation process of a low priority level. Each of the failure detection processes requests memory manipulation by generating an event as the need arises. When the memory manipulation process is activated, it performs the requested memory manipulation in the same order as the memory manipulation is requested so that execution of memory manipulation requested by one of the failure detection processes is not interrupted by execution of memory manipulation requested by the other of the failure detection processes. However, each of the failure detection processes itself can be executed interrupting the execution of memory manipulation process because of its higher priority level.

CROSS REFERENCE TO RELATED APPLICATION

[0001] The present application is based on and incorporates herein by reference Japanese Patent Application No. 2001-78561 filed on Mar. 19, 2001.

BACKGROUND OF THE INVENTION

[0002] 1. Field of the Invention

[0003] The present invention relates to a processor unit for executing a plurality of processes based on priority levels assigned to the processes.

[0004] 2. Related Art

[0005] In an electronic control unit (ECU) installed in a vehicle, some processes included in its control program should be executed in real time for providing the sufficient responsiveness of control and a driver's safety. Accordingly, the control program includes a plurality of processes each of which is a run unit, and one of three priority levels is assigned to each of the processes. Specifically, the control program is composed of three tasks, that is, a high priority task, a moderate priority task, and a low priority task, and the processes are divided into the three tasks. The control program is executed switching among the tasks, so that higher priority processes are preferentially executed. Thus the high priority processes are executed in real time.

[0006] In this case, if processes that have the different priority levels manipulate the same memory area, these processes would interfere with one another as follows. Referring to FIG. 5, a process of lower priority reads one byte (eight bit) data “0000 0000” from the shared memory area at step A. Thereafter switching from the lower priority task to the higher priority task is performed, and a process of higher priority reads the one byte data “0000 0000” from the shared memory area at step C. Then the higher priority process manipulates the data “0000 0000” (i.e., set the least significant bit (LSB)), and writes the resultant data “0000 0001” to the shared memory area at step D. Thereafter the lower priority process manipulates the retrieved data “0000 0000” (i.e., set the second LSB), and writes the resultant data “0000 0010” to the shared memory area at step B. Thus the lower priority process overwrites or resets the LSB that has been set by the higher priority process.

[0007] Further, in the case that the lower priority process repeatedly reads data from the shared memory area, the data to be read by the lower priority process changes halfway if the higher priority process writes data to the shared memory area in between times.

[0008] The ECU usually has a self-diagnostic feature for automatically checking the operating state of computers and sensors included therein at appropriate intervals. If a failure is detected, information on the failure is stored so that the garage mechanic in charge can know the type of the failure.

[0009] The failure detection is performed for various sensors such as a crank angle sensor, a cam angle sensor, and a coolant temperature sensor. The subjects for failure detection number almost 200. Therefore, if memory areas are allocated for storing failure information corresponding to the respective subjects by the byte, the large amount of memory area is required in total. Accordingly it is preferable that memory areas are allocated by the bit for effective use of resources.

[0010] However, the ECU usually employs a reduced instruction set computer (RISC) which does not have a bit manipulation instruction. Therefore, in the ECU, memory areas are allocated for storing failure information by the bit, but memory manipulation is performed by the byte. Accordingly, there is every possibility that a plurality of processes manipulate the same memory area, and therefore there is every possibility that the processes interfere with one another.

[0011] Then, in order to overcome such interference, it is proposed that switching from the lower priority task to the higher priority task is inhibited while the lower priority process performs memory manipulation. In this case, all the higher priority processes are inhibited from being executed interrupting the execution of the lower priority process while the lower priority process performs the memory manipulation. That is, even higher priority processes that do not interfere with the lower priority process are inhibited from interrupting the execution of the lower priority process while the lower priority process performs the memory manipulation. Accordingly execution of high priority processes which should be executed in real time would be delayed, and therefore the sufficient responsiveness of control or a driver's safety is not ensured in this case.

SUMMARY OF THE INVENTION

[0012] The present invention has an object to prevent process interference without delaying execution of high priority processes in a processor unit in which processes of different priority levels manipulate the same memory area.

[0013] A processor unit according to the present invention includes a program to be executed for implementing a series of functions. The program includes a plurality of processes each of which is a run unit. Priority levels are assigned to the respective processes, and the processor unit executes the program switching among the processes based on the priority levels of the processes. Some processes of different priority levels manipulate the same memory area during execution of the program. The program includes a memory manipulation process for implementing memory manipulation as one of the processes. Each of the processes except the memory manipulation process requests memory manipulation by giving a memory manipulation instruction as the need arises, and the memory manipulation process performs the requested memory manipulation in response to the memory manipulation instruction when activated.

[0014] A specific priority level is assigned to the memory manipulation process so that execution of memory manipulation requested by a first process is not interrupted by execution of memory manipulation requested by a second process irrespective of the priority levels of the first and second processes. Preferably, the memory manipulation process performs the requested memory manipulation in the same order as it is requested.

BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The above and other objects, features and advantages of the present invention will become more apparent from the following detailed description made with reference to the accompanying drawings. In the drawings:

[0016]FIG. 1 is a block diagram showing a processor unit according to an embodiment of the present invention incorporated in a vehicle as an engine control unit;

[0017]FIG. 2 is a block diagram showing an engine control program stored in the ROM of the processor unit;

[0018]FIG. 3 is a block diagram showing an event table and queues used for execution of the engine control program;

[0019]FIG. 4A is a schematic diagram showing how memory manipulation requests are stored in the queue of level C;

[0020]FIG. 4B is a graph showing the order in which the memory manipulation requests shown in FIG. 4A are handled according to the embodiment of the present invention; and

[0021]FIG. 5 is a graph showing how processes of different priority levels interfere with each other when memory manipulation is performed according to related art.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENT

[0022] A processor unit according to an embodiment of the present invention is incorporated in a vehicle as an engine control unit (ECU). The ECU controls an internal combustion engine installed in the vehicle. Referring to FIG. 1, the ECU 1 includes a microcomputer 10, an input circuit 21 and an output circuit 22. The input circuit 21 receives analog signals from various sensors 30 that detect the operating state of the engine. The sensors 30 include a crank angle sensor, a reference point sensor, a coolant temperature sensor, an oxygen sensor and the like.

[0023] The crank angle sensor generates a pulse signal whenever the crankshaft further turns for a predetermined angle. The reference point sensor generates a pulse signal whenever the piston of a specific cylinder reaches a predetermined point (e.g., TDC). The coolant temperature sensor detects the temperature of coolant. The oxygen sensor measures the oxygen concentration in exhaust gas. The input circuit 21 shapes the waveform of the received analog signals, and converts the shaped analog signals into digital signals. The resultant signals are outputted to the microcomputer 10.

[0024] The microcomputer 10 includes a CPU 11, ROM 12, RAM 13 and an I/O subsystem 14. The CPU 11 executes various programs based on the signals received from the input circuit 21 for controlling the engine. The ROM 12 stores the programs, which are executed by the CPU 11. The programs mainly include an engine control program. The RAM 13 stores the results of operations and the like during the execution of the programs.

[0025] The I/O subsystem 14 enables the microcomputer 10 to receive signals from the input circuit 21 and output signals to the output circuit 22. The microcomputer 10 further includes various registers, a free running counter and the like. The microcomputer 10 outputs control data as a result of the execution of the programs to the output circuit 22. The output circuit 22 drives actuators 40 installed in the engine in response to the control data received from the microcomputer 10. The actuators 40 include that for an injector (fuel injection system), that for an igniter (ignition device) and the like. Thus the ECU 1 controls the engine based on the signals from the sensors 30.

[0026] Referring to FIG. 2, the engine control program includes a platform (PF) 50 and tasks 61, 62, 63. The PF 50 includes an RTOS 51 which executes the tasks 61, 62, 63 switching among the tasks 61, 62, 63. One of three different priority levels (task levels), that is, a high priority level A, a moderate priority level B, and a low priority level C is assigned to each of the tasks 61, 62, 63. Each of the tasks 61, 62, 63 includes a plurality of event processes each of which is a run unit. A task of a higher priority level is executed in preference to a task of a lower priority level.

[0027] The engine control program includes a failure detection program. The failure detection program includes three event processes, that is, a first failure detection process of level A, a second failure detection process of level B, and a memory manipulation process of level C. According to the assigned priority levels, as shown in FIG. 2, the first failure detection process, the second failure detection process and the memory manipulation process are included in A task 61, B task 62 and C task 63, respectively. The memory manipulation process is provided for storing failure information in memory areas. The memory areas are allocated for the respective pieces of the failure information by the bit.

[0028] Referring to FIGS. 2 and 3, when the PF 50 detects occurrence of an event, it identifies the task 61, 62, 63 that includes an event process corresponding to the detected event by referring to an event table 70. The occurrence of the event is detected based on, for example, the signals from the sensors 30. Further the occurrence of the event may be detected based on the value of the free running counter in the microcomputer 10, or based on information provided by a process on execution.

[0029] The platform 50 stores a request for execution of the event process in the queue 81, 82, 83 corresponding to the identified task 61, 62, 63. That is, if the identified task is A task 61, the request is stored in the queue 81 which is provided for storing requests for execution of processes of level A. Each of the queues 81, 82, 83 is a FIFO (first-in first-out) queue, which is a buffer from which the requests are retrieved in the same order they were stored. Each of the stored requests may include data required for execution of the event process.

[0030] The RTOS 51 identifies the task 61, 62, 63 to be activated by referring to the queues 81, 82, 83, and activates the identified task 61, 62, 63. The RTOS 51 further passes the required data, which is included in the request stored in the queue 81, 82, 83, to the activated task 61, 62, 63. Then the activated task 61, 62, 63 executes the event process.

[0031] Each of the first and second failure detection processes generates an event for instructing memory manipulation during execution of the process, when the memory manipulation should be performed. The event for instructing memory manipulation includes ID of the requester process that has generated the event. The PF 50 detects the generated event. Then the PF 50 stores a request for memory manipulation in the queue 83 of level C as a result of reference to the event table 70 as described above, because the memory manipulation process belongs to C task 63.

[0032] In the case that the second failure detection process generates an event for instructing memory manipulation and thereafter the first failure detection process generates an event for instructing memory manipulation, memory manipulation requests corresponding to the generated events are stored in the queue 83 of level C as shown in FIG. 4A. The memory manipulation requests stored in the queue 83 include the IDs of the second failure detection process and the first failure detection process, respectively.

[0033] If C task 63 is not active but should be activated, the RTOS 51 activates C task 63 only when higher priority tasks 61, 62 are not active and not required to be activated. When C task 63 is activated, the RTOS 51 retrieves requests one by one from the queue 83 and passes, as parameters, the data included in the request to C task 63. Then C task 63 executes the requested process using the received parameters. Therefore, if execution of the memory manipulation process is requested, C task 63 executes the memory manipulation process using the received parameters.

[0034] Specifically, the memory manipulation process first identifies the failure detection process that has requested the memory manipulation based on the ID received as one of the parameters. Then memory manipulation process further identifies the memory area to be manipulated based on the identified failure detection process. Thereafter the memory manipulation process reads data from the identified memory area by the byte. Then the memory manipulation process sets or resets a specific bit of the retrieved byte data, and writes the resultant data to the memory area.

[0035] Thus failure information for which memory areas are allocated by the bit is manipulated by the byte. The memory manipulation process may receive, as some of the parameters, information on the position of the specific bit to be set or reset and whether the specific bit should be set or reset.

[0036] In the case that the memory manipulation requests are stored in the queue 83 as shown in FIG. 4A, memory manipulation requested by the second failure detection process of level B is first performed, and thereafter memory manipulation requested by the first failure detection process of level A is performed as shown in FIG. 4B. Thus memory manipulation is performed by the memory manipulation process in the same order as it is requested irrespective of the priority levels of the failure detection processes that have requested the memory manipulation.

[0037] The engine control program may be provided as a computer readable medium such as FD, MO, CD-ROM, DVD, or a hard disk which stores it. In this case, the engine control program is loaded from the computer readable medium into the RAM 13, and then executed. Further the engine control program may be provided as a computer readable medium such as ROM or backup RAM which stores it. In this case, the computer readable medium is incorporated in the ECU 1.

[0038] According to the present embodiment, the following advantages are provided. Execution of memory manipulation requested by a process is not interrupted by execution of memory manipulation requested by another process, because the memory manipulation process of a specific priority level is provided dedicatedly for performing memory manipulation. However, processes belonging to A task 61 or B task 62 may be executed interrupting execution of the memory manipulation process, because the memory manipulation process has a priority level of C. That is, higher priority processes can be executed in real time.

[0039] Further in the present embodiment, the processor unit according to the present invention is employed for execution of the failure detection program in the ECU 1. In this case, if memory areas are allocated for storing the respective pieces of failure information by the bit and a RISC computer, which manipulates data by the byte, is employed as the ECU 1, there is every possibility that a plurality of process manipulate the same memory area as described above. Therefore the processor unit according to the present invention is effective especially in this case. In other words, the employment of the present processor unit for execution of the failure detection program enables employment of the RISC computer as the ECU 1.

[0040] According to the present embodiment, each of the memory manipulation requests includes the ID of the requester process that has requested the memory manipulation, and the memory manipulation process receives the ID as one of the parameters from the RTOS 51. Therefore, based on the received ID, the memory manipulation process can identify the requester failure detection process and further the memory area to be manipulated. Accordingly, one memory manipulation process can be shared by both the failure detection processes in this case. That is, dedicated memory manipulation processes are not required for the respective failure detection processes. As a result, the entire engine control program can be compact.

[0041] The engine control program corresponds to a program of the present invention. The event generated by the failure detection processes for instructing memory manipulation corresponds to a memory manipulation instruction, and the ID included in the event corresponds to identification information on a requester process.

[0042] (Modifications)

[0043] In the above embodiment, the memory manipulation process may be included in B task 62 or A task 61 instead of C task 63. In this case, the memory manipulation is performed in the same order as it is requested similarly to the above embodiment.

[0044] In the above embodiment, the PF 50 may sort the memory manipulation requests stored in the queue 83 of level C into preferential order based on a predetermined criterion, so that memory manipulation that should be performed in real time may be preferentially performed.

[0045] Further in the above embodiment, dedicated memory manipulation processes may be prepared for the respective failure detection processes. In this case, each of the memory manipulation requests is not required to include the ID of the requester process.

[0046] The present invention is not limited to the above embodiment and modifications, but may be variously embodied within the scope of the invention. 

What is claimed is:
 1. A processor unit for implementing a series of functions comprising a program for implementing said series of functions, said program comprising a plurality of processes each of which is a run unit, wherein said program is executed switching among said plurality of processes based on priority levels assigned to said plurality of processes, and at least two processes of different priority levels manipulate a same memory area during execution of said program, wherein said program includes a memory manipulation process for implementing memory manipulation as one of said plurality of processes, wherein each of said plurality of processes except said memory manipulation process requests memory manipulation by giving a memory manipulation instruction as a need arises during execution of said program, and said memory manipulation process performs the requested memory manipulation in response to said memory manipulation instruction when activated, and wherein a specific priority level is assigned to said memory manipulation process so that execution of memory manipulation requested by a first process is not interrupted by execution of memory manipulation requested by a second process irrespective of priority levels of said first and second processes.
 2. A processor unit as in claim 1, wherein the requested memory manipulation is performed by said memory manipulation process in a same order as it is requested.
 3. A processor unit as in claim 1, wherein said series of functions is provided for failure diagnosis on an on-vehicle device, and wherein said memory manipulation process performs the requested memory manipulation by manipulating failure information on said failure diagnosis based on said memory manipulation instruction given by a requester process that requests the memory manipulation.
 4. A processor unit as in claim 3, wherein memory areas are allocated for respective pieces of said failure information by a bit, and wherein said memory manipulation process manipulates said failure information stored in said memory areas by a byte.
 5. A processor unit as in claim 1, wherein said memory manipulation instruction includes identification information on a requester process that requests the memory manipulation.
 6. A processor unit as in claim 5, wherein said memory manipulation process identifies said requester process based on said identification information, and further identifies a memory area subject to manipulation based on said identified requester process.
 7. A program for implementing a series of functions comprising a plurality of processes, wherein said program is executed switching among said plurality of processes based on priority levels assigned to said plurality of processes, and at least two processes of different priority levels manipulate a same memory area during execution of said program, wherein said program includes a memory manipulation process for implementing memory manipulation as one of said plurality of processes, wherein each of said plurality of processes except said memory manipulation process requests memory manipulation by giving a memory manipulation instruction as a need arises during execution of said program, and said memory manipulation process performs the requested memory manipulation in response to said memory manipulation instruction when activated, and wherein a specific priority level is assigned to said memory manipulation process so that execution of memory manipulation requested by a first process is not interrupted by execution of memory manipulation requested by a second process irrespective of priority levels of said first and second processes.
 8. A system for implementing a series of functions comprising a central processor unit (CPU) and memory means coupled to said CPU, said memory means including a program executed by said CPU for implementing said series of functions, said program comprising a plurality of processes, wherein said CPU executes said program switching among said plurality of processes based on priority levels assigned to said plurality of processes, wherein said program includes a memory manipulation process for implementing memory manipulation as one of said plurality of processes, wherein each of said plurality of processes except said memory manipulation process makes a request for memory manipulation as a need arises during execution of said program, and said memory manipulation process performs the memory manipulation in response to said request when activated, and wherein a specific priority level is assigned to said memory manipulation process so that execution of memory manipulation requested by a first process is not interrupted by execution of memory manipulation requested by a second process irrespective of priority levels of said first and second processes.
 9. A method for implementing a series of functions on a computer, said method comprising the steps of: creating a program for implementing said series of functions so that said program includes a plurality of processes and includes, as one of said plurality of processes, a memory manipulation process for implementing memory manipulation; assigning priority levels to said plurality of processes; and executing said program on said computer switching among said plurality of processes based on the priority levels of said plurality of processes, wherein: each of said plurality of processes except said memory manipulation process makes a request for memory manipulation as a need arises during said executing step, and said memory manipulation process performs the memory manipulation in response to said request during said executing step, and a specific priority level is assigned to said memory manipulation process so that execution of memory manipulation requested by a first process is not interrupted by execution of memory manipulation requested by a second process irrespective of priority levels of said first and second processes. 